package com.andy.web.basedata.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.andy.domain.model.location.City;
import com.andy.domain.model.location.District;
import com.andy.domain.model.location.Province;
import com.andy.web.basedata.service.BasedataService;

/**
 * 用于获取省市区初始数据/(权限不足/异常 -跳转)
 * Edit by Bob.wei. 
 * 2017年7月11日
 * @Email:wbprivate@163.com
 */

@RestController
@RequestMapping("basedata")
public class BasedataController {
	
	@Autowired
	private BasedataService baseDataService;;
	
	@RequestMapping(value = "/getProvinceData")
	public List<Province> getProvinceData() {
		return baseDataService.getAllProvinces();
	}
	
	@RequestMapping(value = "/getCityData/{provinceId}")
	public List<City> getCitysByProvinceId(@PathVariable(value="provinceId")String provinceId) {
		return baseDataService.getCitysByProvinceId(provinceId);
	}
	
	@RequestMapping(value = "/getDistrictData/{cityId}")
	public List<District> getDistrictByCityId(@PathVariable(value="cityId")String cityId) {
		return baseDataService.getDistrictsByCityId(cityId);
	}
}
